Skip to content

Add sending tracks to Garmin Connect as courses - #962

Merged
digitaltom merged 6 commits into
mainfrom
garmin_connect_upload
Nov 15, 2026
Merged

digitaltom merged 6 commits into
mainfrom
garmin_connect_upload

Conversation

@digitaltom

Copy link
Copy Markdown
Collaborator

Users link a Garmin account through OAuth 2.0 PKCE and send a track from the feature modal. A repeated send updates the same course, and Mapforge creates it again if the user deleted it. The success message links to the course in Garmin Connect.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unescaped Garmin error responses create an XSS risk, while uncoordinated concurrent sends can lose course mappings and create duplicate courses.

5 open issues
What changed in this PR

Adds Garmin Connect course export to Mapforge’s track workflow, with account linking and send actions in the feature modal.

Changes:

  • Links Garmin accounts through OAuth 2.0 PKCE and refreshes stored access tokens.
  • Converts tracks into courses, updates previously sent courses, and recreates deleted courses.
  • Adds upload feedback with course links, German translations, and request/model specs.
File Description
spec/​requests/​maps_controller_spec.rb Tests course creation, updates, recreation, and API errors.
spec/​models/​feature_spec.rb Tests course geometry, elevation totals, and activity types.
locale/​de/​app.po Adds German Garmin messages.
locale/​app.pot Adds Garmin translation entries and refreshes source references.
config/​routes.rb Adds the Garmin upload endpoint.
config/​initializers/​omniauth.rb Configures Garmin OAuth with PKCE.
app/​views/​maps/​modals/​_feature.haml Adds Garmin connection and send controls.
app/​models/​user.rb Includes Garmin account functionality.
app/​models/​feature.rb Converts track geometry into Garmin course payloads.
app/​models/​concerns/​garmin_account.rb Handles tokens, course uploads, and saved course IDs.
app/​javascript/​maplibre/​feature/​details.js Shows Garmin export for tracks and sets its URL.
app/​javascript/​controllers/​feature/​modal_controller.js Sends uploads and displays results with course links.
app/​controllers/​sessions_controller.rb Links Garmin credentials to the signed-in user.
app/​controllers/​maps_controller.rb Handles upload requests, metrics, and Garmin errors.

Review effort: Balanced

status(window.__('Garmin Connect login expired, reload the page to connect again'), 'error')
} else {
const error = (await response.json().catch(() => ({}))).error
status(window.__('Error sending to Garmin Connect') + (error ? ': ' + error : ''), 'error')
Comment thread app/models/concerns/garmin_account.rb Outdated
Comment on lines +16 to +19
course_id = garmin_course_ids[feature.id.to_s]
return :updated if course_id && update_garmin_course(token, course_id, course)
created = token.post(COURSE_PATH, course_request(course)).parsed
update!(garmin_course_ids: garmin_course_ids.merge(feature.id.to_s => created["courseId"]))
Comment thread app/models/feature.rb Outdated
segment = va.distance(vb)
steps = (segment / 100).ceil
(1..steps).each do |i|
points << garmin_point(a.zip(b).map { |x, y| x && y && x + (y - x) * i.fdiv(steps) })
Comment thread app/models/feature.rb Outdated
segment = va.distance(vb)
steps = (segment / 100).ceil
(1..steps).each do |i|
points << garmin_point(a.zip(b).map { |x, y| x && y && x + (y - x) * i.fdiv(steps) })
Users link a Garmin account through OAuth 2.0 PKCE and send a track from the feature modal.
A repeated send updates the same course, and Mapforge creates it again if the user deleted it.
The success message links to the course in Garmin Connect.
@digitaltom
digitaltom force-pushed the garmin_connect_upload branch from 718591d to 19f1b2a Compare November 15, 2026 22:49
@digitaltom
digitaltom merged commit 46d6fff into main Nov 15, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants